import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm';

@Entity('sequences')
@Index(['type', 'datePrefix'], { unique: true })
export class Sequence {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({ length: 50, comment: '序列号类型' })
    type: string;

    @Column({ length: 10, comment: '日期前缀，格式：YYYYMMDD' })
    datePrefix: string;

    @Column({ type: 'bigint', default: 0, comment: '当前序列号值' })
    currentValue: number;

    @Column({ type: 'int', default: 1, comment: '步长' })
    step: number;

    @Column({ type: 'int', default: 6, comment: '序列号位数' })
    digits: number;

    @Column({ length: 100, nullable: true, comment: '描述' })
    description: string;

    @Column({ type: 'boolean', default: true, comment: '是否启用' })
    isActive: boolean;

    @CreateDateColumn({ comment: '创建时间' })
    createdAt: Date;

    @UpdateDateColumn({ comment: '更新时间' })
    updatedAt: Date;
}
